<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of EmpleadoDB
 *
 * @author Admin
 */
class Consulta2DB extends CI_Model {

    var $title = '';
    var $content = '';
    var $date = '';

    function __construct() {
        // Call the Model constructor
        parent::__construct();
    }

    function Consulta2($arrData) {
       
        
        $fecha_ini = date($arrData['f_ini']);
        $fecha_fin = date($arrData['f_fin']);
      
        $query = $this->db
                ->select("cod_b,cod_s,COUNT('ci_vig') AS nvig")
                ->from("vigxctt")                
                ->where("f_ini >=",$arrData['f_ini'])
                ->where("f_ini <=",$arrData['f_fin'])                
                ->group_by(array("cod_b","cod_s"))
                ->order_by('cod_b desc, nvig desc')
                ->get();
        return $query->result();  // NO LO HACE REVISAR
    }
   /* SELECT Cod_B, Cod_S, COUNT(CI_Vig)
                    FROM VigxCtt
                    WHERE F_Ini BETWEEN per0 AND per1
                    GROUP BY Cod_B, Cod_S
                    ORDER BY Cod_B, COUNT(CI_Vig) DESC;
    */
}
